package com.yixin.vuehr.web.controller.salary;

import com.yixin.vuehr.bean.RespBean;
import com.yixin.vuehr.bean.RespPageBean;
import com.yixin.vuehr.model.Employee;
import com.yixin.vuehr.model.Salary;
import com.yixin.vuehr.service.EmployeeService;
import com.yixin.vuehr.service.SalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/salary/sobcfg")
public class SalaryConfigController {
    @Autowired
    EmployeeService employeeService;
    @Autowired
    SalaryService salaryService;
    @GetMapping("/")
    public RespPageBean getEmployeeByPageWithSalary(@RequestParam(defaultValue = "1") Integer page,
                                                    @RequestParam(defaultValue = "10")Integer size){
        return employeeService.getEmployeeByPageWithSalary(page,size);
    }
    @GetMapping("/sob")
    public List<Salary> getAllSalary(){
        return salaryService.getAllSalaries();
    }
    @PutMapping("/")
    public RespBean updateEmployeeSalaryById(Integer eid,Integer sid){
        Integer result = employeeService.updateEmployeeSalaryById(eid, sid);
        if (result ==1 || result ==2){
            return RespBean.ok("跟新成功");
        }
        return RespBean.error("跟新失败");
    }
}
